/*
 * Copyright (C) 2021, All rights Reserved, Designed By
 * @author: maoyz
 * @Copyright: 2021-02-24 10:58  Inc. All rights reserved.
 */
package com.myz.cloud.stream.rocketmq.error.producer.producer;


import com.myz.cloud.stream.rocketmq.error.producer.channel.IErrorMessageChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;

/**
 * @author maoyz
 */
@EnableBinding({IErrorMessageChannel.class})
public class ProducerManager implements CommandLineRunner {

    private static final Logger log = LoggerFactory.getLogger(ProducerManager.class);

    @Autowired
    private IErrorMessageChannel errorMessageChannel;

    @Override
    public void run(String... args) throws Exception {
        Thread.sleep(5);
        boolean send = this.errorMessageChannel.error1Output().send(
                MessageBuilder.withPayload(
                        "123"
                ).build());
        log.info("Send {}", send);
    }
}